{% extends "base.html" %}
{% block pagetitle %}{{MSG_PP_USER_PROFILE}}{% endblock %}

{% block content %}
<script type="text/javascript">
function showApplicationBox(type, name) {
  document.getElementById('g_input_type').value = type;
  document.getElementById('g_role_type').innerHTML = name;
  document.getElementById('g_application_box').style.display = 'block';
}
</script>

<h1>{{nickname}}</h2>
<br>
<h2>{{MSG_PP_DESCRIPTION}}</h2>
<div class=art-box>
  {{description}}
</div>

<h2>{{MSG_PP_ROLES}}:</h2>
<div class=art-box>

{% if is_self %}
  {% for role in role_types %}
     <p>{{role.name}}
    {% ifequal role.state "new" %}
    [<a style="cursor:pointer" 
         onclick='showApplicationBox("{{role.type}}", "{{role.name}}")'>{{MSG_PP_APPLY}}</a>]
    {% endifequal %}
    {% ifequal role.state pending" %}
      [<font color=red>{{MSG_PP_PENDING}}</font>]
    {% endifequal %}
    {% ifequal role.state "current" %}
      [<font color=green>{{MSG_PP_ACTIVE}}</font>]
    {% endifequal %}
  {% endfor %}
{% else %}
  {% for role in role_types %}
    {% ifequal role.state "current" %}
     <p>{{role.name}} [<font color=green>{{MSG_PP_ACTIVE}}</font>]
    {% endifequal %}
  {% endfor %}
{% endif %}
  
  <div id="g_application_box" style="display:none" >
  <h3> Applying for <font color=red id=g_role_type></font>.</h3>
  <form class="art-form-left" action="/profile" method="post">
    <textarea name="reason">Tell us why we should approve you.</textarea>
    <input id='g_input_type'type="hidden" name="type" />
    <br>
    <input type="hidden" name="post_action" value="create" />
    <input type="submit" value="Submit" />
  </form>
  </div>
{% if is_admin_profile %}
<a href="/approvals">{{MSG_PP_VIEW_APPROVALS}}</a>
{% endif %}
</div>

<h2>{{MSG_PP_DONOR_PROFILES}}:</h2>
<div class=art-box>
{% for profile in donor_profiles %}
  {% include "donor_profile.html" %}
{% endfor %}
{% if is_self %}
<a href="/createprofile?type=donor">{{MSG_PP_APPLY_DONOR_PROFILE}}</a>
{% endif %}
</div>

<h2>{{MSG_PP_MANUFACTURER_PROFILES}}:</h2>
<div class=art-box>
{% for profile in manufacturer_profiles %}
  {% include "manufacturer_profile.html" %}
{% endfor %}

{% if is_self %}
<a href="/createprofile?type=manufacturer">{{MSG_PP_APPLY_MANUFACTURER_PROFILE}}</a>
{% endif %}
</div>

{% endblock %}
